using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        private ControlTemplate template;

        public Window1()
        {
            InitializeComponent();
            var style = new Style();
            var setter = new Setter();
            setter.Property = Button.FontFamilyProperty;
            style.Setters.Add(setter);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            new Window2().ShowDialog();
        }

        private void TextBox_Initialized(object sender, EventArgs e)
        {
            var textBox = (TextBox)sender;
            template = (ControlTemplate) FindResource("MyTexBoxTemplate");
            textBox.Template = template;
            //var controlTemplate = new ControlTemplate();
            //var frameworkElementFactory = new FrameworkElementFactory();
            //controlTemplate.VisualTree = frameworkElementFactory;
            //textBox.Template = controlTemplate;
        }

        private void Border_Initialized(object sender, EventArgs e)
        {
            //var it = (Border)sender;
            //it.BorderThickness(5).Padding(new Thickness(5)).BorderBrush(
            //    new SolidColorBrush().Color(Color.FromRgb(204, 0, 0))
            //    );

        }
    }
}
